import React, { PureComponent } from 'react';
import style from '../index.less';
import { connect } from 'dva';
import { CardC, IconC, InputC, BenchMarkC, ProductListC } from '../../../../comps';
import uuid from 'es6-uuid';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import { Row, Col } from 'antd';
const FormItem = Form.Item;
@Form.create()
class CommonFormC extends PureComponent {
  state = {};
  componentDidMount() {
    this.props.onRef(this);
  }
  getFormData = () => {
    const {
      form: { validateFields },
    } = this.props;
    let query = {};
    validateFields((err, fieldsValue) => {
      if (!err) {
        query = fieldsValue;
        query.portfolioCode = typeof query.portfolioCode == 'string' ? (query.portfolioCode.length ? query.portfolioCode : null) : null;
      } else {
        query = undefined;
      }
    });
    return query;
  };

  render() {
    const { info = {}, type } = this.props;
    return (
      <div>
        <Row>
          <Col span={8}>
            <InputC title={'组合代码'} form={this.props.form} dataIndex='portfolioCode' initialValue={info.portfolioCode} max={50} />
          </Col>
          <Col span={8}>
            <InputC
              title={'组合名称'}
              form={this.props.form}
              dataIndex='portfolioName'
              initialValue={info.portfolioName}
              max={100}
              rules={[{ required: true, message: '请输入组合名称!' }]}
            />
          </Col>
          <Col span={8}>
            <BenchMarkC title='关联业绩基准' form={this.props.form} dataIndex='benchMark' initialValue={info.benchMark} />
          </Col>
          <Col span={8}>
            <ProductListC form={this.props.form} initialValue={info.productId} title='关联产品' dataIndex='productId' dataType={4} due={1} />
          </Col>
        </Row>
      </div>
    );
  }
}
export default CommonFormC;
